$(function() {
	var map, encodedPolyline = null;
	//Google api key = ABQIAAAAxRW0bkda2rrzoACHUIF9NxStud-h1rCQ67pMFslJs6oGqC9crBTbrz8OOhPMHB29HdqOyzEpkbLOpw
	$.getScript('http://www.google.com/jsapi?key=ABQIAAAAxRW0bkda2rrzoACHUIF9NxStud-h1rCQ67pMFslJs6oGqC9crBTbrz8OOhPMHB29HdqOyzEpkbLOpw', function() {
		google.load('maps', 2, {'callback': mapsloaded});
	});
	$('#gomyhome').click(
		function() {
			polyline({
				color: '#F00',
				points: '{zzwCy{tdV{JqFp@yHXaDNiENgHLiEbA}GfAwFpDeQz@qEdBqJdByKNqH\\yNJ{FIcFi@uKu@{KDiGZ_Hb@iIt@{MLcG{@gJwAeMmMi`@yDcO}BdAeAoUgBmIUgHMmd@sAwIgDkKsIyYOkKgAeJoD{N]{CKsG^mHfBoKhBwMkI_{@cA}MDsHX_O~@qLJmGg@aGl@wOhB{IvAmJWmCiAgEmBmGyIaKmA{ABqBlCsJ|@_GBaGcBiJeEsHsEoFwCeD_EuGeBsEgBuIm@kNCgB}@yHiYk|@_CuI_B_HaB\\',
				levels: 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'
			});
		}
	);
	$('#go101').click(
		function() {
			polyline({
				color: '#F00',
				points: 'o{zwC}{tdVrUuqAxCsPrAqTR{YReX\\gl@d@{hAjr@d^RgXmFSp@wF',
				levels: 'BBBBBBBBBBBB'
			});
		}
	);
	function mapsloaded() {
		map = new google.maps.Map2(document.getElementById("maps"));
		map.setMapType(G_HYBRID_MAP);
		map.setCenter(new google.maps.LatLng(25.046517, 121.521338), 15);
		map.addControl(new google.maps.MapTypeControl());
		map.addControl(new google.maps.LargeMapControl());
		//map.addControl(new google.maps.SmallMapControl());
		//map.addControl(new google.maps.SmallZoomControl());
		map.addControl(new google.maps.ScaleControl());
		map.addControl(new google.maps.HierarchicalMapTypeControl());
		map.addControl(new google.maps.OverviewMapControl());
		map.addOverlay(new GStreetviewOverlay());
		google.maps.Event.addListener(map, 'click',
			function (overlay, latlng) {
				//$('#google_street_view').window();
				$.platform.app({
					runat: 'client',
					app: 'google',
					sub_app: 'maps',
					method: 'streetView',
					params: {
						lat: latlng.lat(),
						lng: latlng.lng()
					}
				});
			}
		);
	}
	function polyline(options) {
		if (encodedPolyline != null) {
			map.removeOverlay(encodedPolyline);
		}
		encodedPolyline = new google.maps.Polyline.fromEncoded({
			color: options.color,
			weight: 10,
			points: options.points,
			levels: options.levels,
			zoomFactor: 32,
			numLevels: 4
		});
		map.addOverlay(encodedPolyline);
	}
});